*** Settings ***
Library  Selenium2Library
Resource  ../resource/Platform1.0Keywords.robot

*** Test Cases ***
logintest
    [Documentation]  登录成功
    LoginSystem
    # 获取登录成功首页系统管理菜单按钮的元素文字
    ${menuText}  get text  id=10000000
    log to console  ${menuText}
    # 获取的元素文字中应该包含
    should contain  ${menuText}  ${sysResult}
    wait until element is not visible  xpath=//div[@class='bd clearfix']//h2  1
    ${coo}  get cookies
    log to console  ${coo}
    # 抓包获取cookie的name是SHAREJSESSIONID，它的值是字典的形式
    ${cookies}  get cookie  SHAREJSESSIONID
    log to console  ${cookies}
    set global variable  ${cookies}
    close browser

logfailtest
    [Documentation]  密码错误用例
    open browser  ${url}  chrome
    # 输入正确的用户名
    input text  id=username  ${userName}
    # 输入错误的密码
    input text  id=password  1111
    # 点击登录按钮
    click element  id=submit
    # 登录页面的元素
    ${exceptMsg}  get text  xpath=//div[@class='bd clearfix']//h2
    should be equal  ${exceptMsg}  登录工作平台
    close browser

*** Keywords ***
LoginSystem
    [Documentation]  打开浏览器，登录平台1.0系统
    # 打开浏览器，输入网址
    open browser  ${url}    chrome
    # 设置浏览器等待时间为10秒
    set browser implicit wait  10
    # 输入用户名
    input text  id=username  ${userName}
    # 输入密码
    input password  id=password  ${pwd}
    # 点击登录按钮
    click element  id=submit

*** Variables ***

${sysResult}  系统
